<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<script>
    /*
    * 返回两个日期之间的所有时期
    * 如 dataScope('2017-08-01','2017-08-10')
    * 返回  ["2017-8-01", "2017-8-02", "2017-8-03", "2017-8-04", "2017-8-05",
    *       "2017-8-06", "2017-8-07", "2017-8-08", "2017-8-09", "2017-8-10"]
    */
    function dataScope(value1, value2) {
        var getDate = function(str) {
            var tempDate = new Date();
            var list = str.split("-");
            tempDate.setFullYear(list[0]);
            tempDate.setMonth(list[1] - 1);
            tempDate.setDate(list[2]);
            return tempDate;
        }
        var date1 = getDate(value1);
        var date2 = getDate(value2);
        if (date1 > date2) {
            var tempDate = date1;
            date1 = date2;
            date2 = tempDate;
        }
        date1.setDate(date1.getDate());
        var dateArr = [];
        var i = 0;
        while (!(date1.getFullYear() == date2.getFullYear() && date1.getMonth() == date2.getMonth() && date1.getDate() == date2.getDate()+1)) {
            var dayStr =date1.getDate().toString();
            if(dayStr.length ==1){
                dayStr="0"+dayStr;
            }
            dateArr[i] = date1.getFullYear() + "-" + (date1.getMonth() + 1) + "-"
                + dayStr;
            i++;
            date1.setDate(date1.getDate() + 1);
        }
        return dateArr;
    }
    console.log(dataScope('2017-07-15 12:00','2017-08-15 12:00'))

</script>
</body>
</html>